﻿using OpenVision.Models;
using OpenVisionWebService.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace OpenVisionWebService.Models
{
    public class UserDetailsModel : UserModel
    {
        public UserDetailsModel()
        {
        }

        public UserDetailsModel(int id, string nickname, string email)
        {
            this.Id = id;
            this.Nickname = nickname;
            this.Email = email;
        }

        public static Expression<Func<User, UserDetailsModel>> FromUser
        {
            get
            {
                return x => new UserDetailsModel
                {
                    Id = x.Id,
                    Nickname = x.Nickname,
                    Email = x.Email,
                };
            }
        }

        public static UserDetailsModel CreateModel(User user)
        {
            UserDetailsModel model = new UserDetailsModel(user.Id, user.Nickname, user.Email);

            return model;
        }

        public User ToUser()
        {
            User user = new User()
            {
                Id = this.Id,
                Nickname = this.Nickname,
                Email = this.Email,
            };

            return user;
        }
    }
}